package com.pixiv.tools;

import cn.hutool.json.JSONObject;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

public class SendPack {
    public static void flag(HttpServletResponse resp, int var)
    {
        PrintWriter pw = null;
        try {
            pw = resp.getWriter();
            pw.write("{\"flag\":" + var +"}");
            pw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }
    public static void state(HttpServletResponse resp, int var)
    {
        PrintWriter pw = null;
        try {
            pw = resp.getWriter();
            pw.write("{\"state\":" + var +"}");
            pw.close();
        } catch (IOException e) {
            e.printStackTrace();
        }

    }

    public static String getFlag(int v){
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("flag",v);
        return jsonObject.toString();
    }

    public static String getState(int v){
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate("state",v);
        return jsonObject.toString();
    }
    public static String get(String vectorName,int v)
    {
        JSONObject jsonObject = new JSONObject();
        jsonObject.accumulate(vectorName,v);
        return jsonObject.toString();
    }

}
